X-Git-Url: http://git.cyclocoop.org/%27%20.%20%24prefix%20.%20Wiki::transformTitleToURI%28%24matches%5B1%5D%29%20.%20%27?a=blobdiff_plain;f=includes%2Flibs%2FMapCacheLRU.php;h=db6869bd5328a51fbf1f145eb91ad1500b9b24b4;hb=70c2223843b6e7e41457ec6469c3f34a3860cd59;hp=2f5a454f5ddbe3880b7d86d4715351d9ed115314;hpb=d44c9dfa3a0d16cfbaa21281396c063ebe09eaf4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index 2f5a454f5d..db6869bd53 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -58,7 +58,7 @@ class MapCacheLRU { * @return void */ public function set( $key, $value ) { - if ( array_key_exists( $key, $this->cache ) ) { + if ( $this->has( $key ) ) { $this->ping( $key ); } elseif ( count( $this->cache ) >= $this->maxCacheKeys ) { reset( $this->cache ); @@ -75,6 +75,9 @@ class MapCacheLRU { * @return bool */ public function has( $key ) { + if ( !is_int( $key ) && !is_string( $key ) ) { + throw new MWException( __METHOD__ . ' called with invalid key. Must be string or integer.' ); + } return array_key_exists( $key, $this->cache ); } @@ -87,7 +90,7 @@ class MapCacheLRU { * @return mixed Returns null if the key was not found */ public function get( $key ) { - if ( !array_key_exists( $key, $this->cache ) ) { + if ( !$this->has( $key ) ) { return null; }